package com.um.jdy.platform.shop.controller;


import com.um.jdy.platform.shop.entity.dto.DiyGetDTO;
import com.um.jdy.platform.shop.manager.DiyManager;
import com.um.jdy.common.shop.service.DiyService;
import com.um.jdy.common.shop.entity.po.Diy;
import com.um.jdy.common.shop.entity.dto.DiyDTO;
import com.um.jdy.common.shop.entity.vo.DiyVO;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.TokenRequired;
import com.um.springboot.starter.orm.controller.BasePlusController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.manager.BasePlusManager;
import com.um.springboot.starter.orm.params.ListDTO;
import com.um.springboot.starter.orm.params.PageDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 控制器：页面diy表
 */
@RestController
@RequestMapping("/api/v1/cms/shop/diy")
@Api(tags = "DiyController", description = "页面diy表")
@ApiPermission("diy")
@TokenRequired
public class DiyController extends BasePlusController<DiyManager,DiyService,Diy,DiyDTO,DiyVO, PageDTO, ListDTO> {

    @ApiPermission("get")
    @ApiOperation("查询DIY")
    @PostMapping("get")
    public Response<DiyVO> get(@RequestBody DiyGetDTO diyGetDTO) {
        DiyVO diyVo = manager.get(diyGetDTO);
        return Response.success(diyVo);
    }

    @ApiOperation("查询主页DIY")
    @PostMapping("get_home")
    public Response<DiyVO> getHome(@RequestBody DiyGetDTO diyGetDTO) {
        DiyVO diyVo = manager.get(diyGetDTO);
        return Response.success(diyVo);
    }

    @ApiOperation("更新主页DIY")
    @PutMapping({"/home/{id}"})
    public Response<Diy> updateHome(@PathVariable String id, @RequestBody DiyDTO dto) {
        return manager.updateEntity(id, dto);
    }

}
